<template>
  <div>
    <van-nav-bar
      title="我的"
      left-text="返回"
      right-text="退出登录"
      left-arrow
      @click-left="$router.push('/index')"
      @click-right="onClickRight"
    />
    <van-contact-card
      type="edit"
      :name="currentContact.name"
      :tel="currentContact.tel"
    />
  </div>
</template>

<script>
export default {
  // 组件名称
  name: "demo",
  // 组件参数 接收来自父组件的数据
  props: [],
  // 局部注册的组件
  components: {},
  // 组件状态值
  data() {
    return {
      currentContact: {
        name: "李二蛋",
        tel: "",
      },
    };
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      console.log(vm);
      if (vm.$store.state.token == "") {
        vm.$router.push("/login");
      }
    });
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {
    onClickRight() {
      this.$store.commit("removeuser");
      this.$router.push("/login");
    },
  },
  //生命周期
  created() {},
  mounted() {
    this.currentContact.tel = this.$store.state.user.uid 
  },
};
</script> 

<style scoped>
</style>
